package com.tj.ocr.img.sim;

public class SimString {

	private int width;
	private long print;
	private int header;
	private int footer;
	
	public SimString(int width, long print, int header, int footer){
		this.width = width;
		this.print = print;
		this.header = header;
		this.footer = footer;
	}
	
	public String toString(){
		return String.valueOf(width) + "@"
				+ this.print + "@"
				+ this.header + "@"
				+ this.footer;
	
	}
	
	public static SimString parse(String text) {
		if(text == null){
			System.out.println("invalid text(null)");
			return null;
		}
		
		String[] cs = text.split("@");
		if(cs.length < 4){
			System.out.println("invalid text(too short@):" + text);
			return null;
		}
		
		return new SimString(Integer.parseInt(cs[0]),
				Long.parseLong(cs[1]),
				Integer.parseInt(cs[2]),
				Integer.parseInt(cs[3]));
	}
}
